import moment from 'moment'

// 日期格式化
export function dateformat (timeStamp, formatStr) {
  if (!timeStamp) {
    return ''
  }
  let time = moment(Number(timeStamp))
  return time.format('YYYY-MM-DD HH:mm:ss')
}

export function productStatus (status) {
  let statusHash = {
    '0': '尚未上架',
    '1': '出售中',
    '2': '下架',
    '3': '即将开售',
    '4': '定时上架'
  }
  return statusHash[status] || ''
}

export function price (val) {
  if (!val) {
    return ''
  }
  let price = Number(val) / 100
  return '¥' + price.toFixed(2) || ''
}

export function activityTypeContent (val) {
  let content = ''
  switch (val) {
    case 1:
      content = '立减活动'
      break
    default:
      content = '未知'
      break
  }
  return content
}
// 营销活动状态
export function displayActivityStatusContent (val) {
  let content = {
    1: '未启动',
    2: '待生效',
    3: '生效中',
    4: '停止',
    5: '失效'
  }
  return content[val] || '未知'
}
// 积分策略
export function displayIntegralStatusContent (val) {
  let content = {
    1: '待生效',
    2: '生效中',
    3: '已失效'
  }
  return content[val] || '未知'
}
